#ifndef __LAYER_H_
#define __LAYER_H_

#include <tf2_ros/buffer.h>
#include <nav_msgs/OccupancyGrid.h>
#include <sensor_msgs/PointCloud2.h>
#include "costmap_2d.h"
#include "layered_costmap.h"
#include "layers/observation_buffer.h"

using namespace std;

namespace costmap_2d{
    class LayeredCostmap;    //前向引用
    class ObservationBuffer;    //前向引用

    class Layer{
        public:
            Layer();
            void initialize(LayeredCostmap* parent, std::string name, tf2_ros::Buffer *tf);

            virtual ~Layer() {}
            virtual void onInitialize() {}
            virtual void matchSize() = 0;
            virtual void setMap(const nav_msgs::OccupancyGridConstPtr& new_map) = 0;
            virtual void createBuffer(boost::shared_ptr<costmap_2d::ObservationBuffer> buffer, string topic_name) = 0;
            virtual void addPointCloud2(sensor_msgs::PointCloud2 cloud, string topic_name) = 0;
            virtual void updateBounds(double robot_x, double robot_y, double robot_yaw, double* min_x, double* min_y,
                double* max_x, double* max_y) {}
            virtual void updateCosts(Costmap2D& master_grid, int min_i, int min_j, int max_i, int max_j) {}

        protected:
            LayeredCostmap* layered_costmap_;
            std::string name_;
            tf2_ros::Buffer *tf_;
    };

}   // namespace costmap_2d

#endif